//
//  MyCollectionReusableView.m
//  22-QQMusic
//
//  Created by Snow on 16/8/13.
//  Copyright © 2016年 Snow. All rights reserved.
//

#import "MyCollectionReusableView.h"
#define kWidth self.frame.size.width
#define kHeight self.frame.size.height


@interface MyCollectionReusableView ()
@property (nonatomic, strong) UIImageView *flagImage;
@property (nonatomic, strong) UIButton *button;
@end
@implementation MyCollectionReusableView
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        _flagImage = [[UIImageView alloc] init];
        _labelOfNum = [[UILabel alloc] init];
        _labelOfTitle = [[UILabel alloc] init];
        _labelOfContent = [[UILabel alloc] init];
        _image = [[UIImageView alloc] init];
        _labelOfHeaderTitle = [[UILabel alloc] init];
        _button = [UIButton buttonWithType:UIButtonTypeCustom];
        [self addSubview:_button];
        [self addSubview:_labelOfTitle];
        [self addSubview:_labelOfContent];
        [self addSubview:_image];
        [self addSubview:_labelOfHeaderTitle];
        [_image addSubview:_labelOfNum];
        [_image addSubview:_flagImage];
    }
    return self;
}
- (void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes
{
    [super applyLayoutAttributes:layoutAttributes];
    _button.frame = CGRectMake(kWidth - 30, 15, 20, 20);
    [_button setImage:[UIImage imageNamed:@"Unknown-5"] forState:UIControlStateNormal];
    _labelOfHeaderTitle.frame = CGRectMake(0, 0, kWidth - 30, kHeight / 6);
    _image.frame = CGRectMake(0, kHeight / 6, kWidth,kHeight / 2);
    _image.image = [UIImage imageNamed:@"14691424_1351245180941"];
    _labelOfNum.frame = CGRectMake(20, _image.frame.size.height / 8 * 7 - 10, _image.frame.size.width, _image.frame.size.height / 8);
    _labelOfNum.font = [UIFont systemFontOfSize:12];
    _labelOfNum.text = @"最新上架";
    _flagImage.frame = CGRectMake(4, _image.frame.size.height / 8 * 7 - 8, 16, 16);
    _flagImage.image = [UIImage imageNamed:@"1"];
    _labelOfTitle.frame = CGRectMake(0, kHeight / 3 * 2, kWidth, kHeight / 6);
    _labelOfTitle.text = @"李光洙";
    _labelOfContent.frame = CGRectMake(0, kHeight / 6 * 5, kWidth, kHeight / 6);
    _labelOfContent.text = @"当今世上, 我最英俊";
    _labelOfContent.font = [UIFont systemFontOfSize:12];
}


@end
